Pin light theme on /workspaces/ at wrapper scope#772
Merged
Conversation
The earlier force-light approach (adding the `.light` class to <html>
from a head script) gets undone the moment the React ModeToggleIsland
hydrates: its mount effect always calls `classList.remove('light')`
before re-applying based on the saved cookie. If the visitor's saved
theme is dark, the page flashes light then flips to dark.
Inline the light theme tokens inside `.ws-force-light` instead. The
toggle component can still flip the global `.light` class on/off, but
the workspaces page's tokens are pinned at the wrapper scope and
unaffected. Result: deterministic light mode regardless of the
visitor's saved preference.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #771. The earlier "force light mode on
/workspaces/" change added the.lightclass to<html>via a head-slot inline script. That works for the first paint, but then gets undone:The
ModeToggleIslandReact component inNav.astrohydrates on mount and runsapplyTheme(theme), which always callsclassList.remove('light')first before re-applying based on the saved theme cookie. So if a visitor's saved theme is dark, the page flashes light then flips to dark a few hundred ms later — which is what was happening in production after #771 merged.Fix
Pin the light-theme CSS variables inside a
.ws-force-lightwrapper scope on the workspaces page. The toggle component can still flip the global.lightclass on/off, but the workspaces page's tokens are locked in at the wrapper level and aren't affected.Net effect:
/workspaces/is deterministically light regardless of the visitor's saved theme preference, and the rest of the site continues to honor the toggle as before.Test plan
https://plannotator.ai/workspaces/withplannotator-theme=darkcookie set → page renders light, doesn't flashplannotator-theme=light→ still light (unchanged)/docs/after merging → renders dark (or whatever the saved theme is), confirming the override is page-scoped/workspaces/→ toggle still works on the rest of the site if you navigate away;/workspaces/itself stays lightGenerated with Devin